var express = require('express');
var router = express.Router();
var {adminModel, routeModel, studentModel} = require('../model/model')

router.post('/back_login', async(req, res) => {
    let {name, password} = req.body
    let result = await adminModel.find({$and: [{name}, {password}]})
    if(result.length > 0){
        console.log(result[0])
        res.send({
            code: 200,
            mess: '登陆成功'
        })
    }else{
        res.send({
            code: 404,
            mess: '登录失败, 请检查用户名或密码'
        })
    }
})

router.get('/get_home', async(req, res) => {
    let {uid} = req.query
    
})

router.post('/examlogin', async(req, res) => {
    let {name, card, tid} = req.body
    let result = await studentModel.find({$and: [{name}, {card}, {tid}]})
    if(result.length > 0){
        res.send({
            code: 201,
            sid: result[0]._id
        })
    }else{
        res.send({
            code: 404,
            sid: ''
        })
    }
})

router.get('/in', (req, res) => {
    res.send({
        code: 200,
        data: '滋滋滋资质'
    })
})
module.exports = router;